home *** CD-ROM | disk | FTP | other *** search
/ ftp.alaska-software.com / 2014.06.ftp.alaska-software.com.tar / ftp.alaska-software.com / 3pp / mxsetup.old / {app} / MxRegVal.prg < prev    next >
Text File  |  2001-09-28  |  2KB  |  77 lines

  1. //////////////////////////////////////////////////////////////////////
  2. //
  3. //  MxRegVal.prg
  4. //
  5. //  Copyright:
  6. //      Maniacc Software Inc., (c) 1999. All rights reserved.
  7. //
  8. //  Contents:
  9. //      Retrieves values from the Registry using Thomas Braun's RegClass
  10. //      - MxGetFont() --> cFontCompoundName (complete with point size)
  11. //                           ie:  "10.MS Sans Serif Bold"
  12. //
  13. //////////////////////////////////////////////////////////////////////
  14.  
  15. #include "regclass.ch"
  16. #include "xbp.ch"
  17. #include "nls.ch"
  18.  
  19. FUNCTION MxGetFont( cWinFont )
  20.  
  21.     LOCAL oReg
  22.     LOCAL nPtSize, nSkip, nName, i
  23.     LOCAL cRegFont, cFontCompoundName
  24.     LOCAL aFontTypes := {"CaptionFont","SmCaptionFont","MenuFont","StatusFont","MessageFont","IconFont"}
  25.  
  26.     cWinFont := iif(!empty(cWinFont),cWinFont,aFontTypes[5])
  27.         // can be "CaptionFont"        or 1
  28.         //        "SmCaptionFont"    or 2
  29.         //        "MenuFont"        or 3
  30.         //        "StatusFont"        or 4
  31.         //        "MessageFont"        or 5
  32.         //        "IconFont"        or 6
  33.  
  34.     if valtype(cWinFont)=="N"
  35.         cWinFont := aFontTypes[cWinFont]
  36.     endif
  37.  
  38.     oReg := XbpReg():NEW( "HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics" )
  39.     if ! oReg:Status()
  40.         oReg:Create()
  41.     endif    
  42.     oReg:ReadBinType("C")
  43.     cRegFont := oReg:GetValue( cWinFont )    // Get the entire String from the Registry
  44.  
  45.     nPtSize := Bin2i( cRegFont )
  46.     if len(cRegFont) > 60
  47.         nSkip := 2
  48.         nPtSize := round(abs(0.75*nPtSize),0)
  49.     else
  50.         nSkip := 1
  51.     endif
  52.         
  53.     cFontCompoundName := alltrim(str(nPtSize))+"."
  54.     i := 1+(10*nSkip)+8
  55.     do while i<=len(cRegFont) .and. asc(cRegFont[i])<>0
  56.         cFontCompoundName := cFontCompoundName+cRegFont[i]
  57.         i := i+nSkip
  58.     enddo
  59.  
  60.  
  61.     cFontCompoundName := iif(Bin2i(subStr(cRegFont,1+(8*nSkip),2))>=XBPFONT_WEIGHT_BOLD,;
  62.                              cFontCompoundName+" Bold",;
  63.                              cFontCompoundName)
  64.     cFontCompoundName := iif(asc(cRegFont[1+(10*nSkip)])==1,;
  65.                              cFontCompoundName+" Italic",;
  66.                              cFontCompoundName)
  67.     // If the following is true, the display should be Russian (codepage 204)
  68.     cFontCompoundName := iif(asc(cRegFont[1+(13*nSkip)])==204,;
  69.                              cFontCompoundName+" (Cyrillic)",;
  70.                              cFontCompoundName)
  71.     if asc(cRegFont[1+(13*nSkip)])==204
  72. //        setLocale(NLS_IOEMCP,"204")
  73.     endif
  74.  
  75. RETURN cFontCompoundName
  76.  
  77.